package com.example.demo69.controller;

import com.example.demo69.entity.User;
import com.example.demo69.service.UserService;
import com.example.demo69.vo.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class UserController {

    @Autowired
    UserService userService;

    @GetMapping("/query")
    public List<User> queryUserList(PageInfo pageInfo){
        System.out.println(pageInfo);
        return userService.queryUserList(pageInfo);
    }

    @PostMapping("/insert")
    public void insert(@RequestBody User user){
        userService.insert(user);
    }

    @DeleteMapping("/delete/{id}")
    public void delete(@PathVariable("id") int id){
        userService.delete(id);
    }

    @PostMapping("/update")
    public void update(@RequestBody User user){
        userService.update(user);
    }
}
